import 'package:flutter/material.dart';

// ئۆرنەك مال ئۇچۇرى ئۈچۈن بىر سىنىپ
class InventoryItem {
  final String id;
  final String name;
  final int quantity;
  final double price;
  final String imageUrl; // رەسىم ئۈچۈن URL (ئەگەر بولسا)

  InventoryItem({
    required this.id,
    required this.name,
    required this.quantity,
    required this.price,
    this.imageUrl = '', // كۆڭۈلدىكى قىممەت بوش
  });
}

class InventoryManagementScreen extends StatefulWidget {
  const InventoryManagementScreen({Key? key}) : super(key: key);

  @override
  _InventoryManagementScreenState createState() => _InventoryManagementScreenState();
}

class _InventoryManagementScreenState extends State<InventoryManagementScreen> {
  // ئۆرنەك مال تىزىملىكى
  final List<InventoryItem> _inventoryItems = [
    InventoryItem(id: '1', name: 'ئالما كومپيۇتېر MacBook Pro 14"', quantity: 5, price: 15000.00, imageUrl: 'https://via.placeholder.com/150/771796'), // ئۆرنەك رەسىم URL
    InventoryItem(id: '2', name: 'سامسۇڭ Galaxy S23 Ultra', quantity: 12, price: 8500.00, imageUrl: 'https://via.placeholder.com/150/24f355'),
    InventoryItem(id: '3', name: 'Logitech MX Master 3S مائۇس', quantity: 30, price: 750.00),
    InventoryItem(id: '4', name: 'Dell UltraSharp U2723QE ئېكران', quantity: 8, price: 4500.00, imageUrl: 'https://via.placeholder.com/150/d32776'),
    InventoryItem(id: '5', name: 'خۇاۋېي MatePad Pro 11 تابلېت', quantity: 15, price: 3800.00),
    InventoryItem(id: '6', name: 'Sony WH-1000XM5 تىڭشىغۇچ', quantity: 22, price: 2800.00, imageUrl: 'https://via.placeholder.com/150/f66b97'),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('ئامبار باشقۇرۇش'),
        centerTitle: true,
        backgroundColor: Colors.teal,
        actions: [
          IconButton(
            icon: const Icon(Icons.search),
            onPressed: () {
              // TODO: ئىزدەش ئىقتىدارىنى قوشۇش
            },
          ),
          IconButton(
            icon: const Icon(Icons.filter_list),
            onPressed: () {
              // TODO: سۈزگۈچ ئىقتىدارىنى قوشۇش
            },
          ),
        ],
      ),
      body: ListView.builder(
        itemCount: _inventoryItems.length,
        itemBuilder: (context, index) {
          final item = _inventoryItems[index];
          return Card(
            margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
            elevation: 2,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10),
            ),
            child: ListTile(
              leading: CircleAvatar(
                backgroundColor: Colors.teal[50],
                // رەسىم بولسا كۆرسىتىش، بولمىسا باش ھەرپنى كۆرسىتىش
                backgroundImage: item.imageUrl.isNotEmpty ? NetworkImage(item.imageUrl) : null,
                child: item.imageUrl.isEmpty
                    ? Text(
                        item.name.isNotEmpty ? item.name[0] : '?', 
                        style: const TextStyle(color: Colors.teal, fontWeight: FontWeight.bold)
                      )
                    : null,
              ),
              title: Text(item.name, style: const TextStyle(fontWeight: FontWeight.w600)),
              subtitle: Text('سانى: ${item.quantity} | باھاسى: ¥${item.price.toStringAsFixed(2)}'),
              trailing: IconButton(
                icon: const Icon(Icons.more_vert, color: Colors.grey),
                onPressed: () {
                  // TODO: تەپسىلات ياكى تەھرىرلەش/ئۆچۈرۈش ئىقتىدارى
                },
              ),
              onTap: () {
                 // TODO: مال تەپسىلاتى بېتىگە يۆتكەش
              },
            ),
          );
        },
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // TODO: يېڭى مال قوشۇش بېتىگە يۆتكەش
        },
        backgroundColor: Colors.teal,
        child: const Icon(Icons.add),
        tooltip: 'يېڭى مال قوشۇش',
      ),
    );
  }
} 